package com.by.controller;

import com.by.bean.Car;
import com.by.common.bean.ResultBean;
import com.by.common.controller.BaseController;
import com.by.service.CarService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "购物车")
@RequestMapping("/v1")
public class CarController extends BaseController {

    @Autowired
    CarService carService;

    @ApiOperation("加入购物车")
    @PostMapping("/car")
    public ResultBean addCar(@RequestBody Car car) {
        carService.addCar(car);
        return success("加入购物车");
    }
    @ApiOperation("查看购物车")
    @GetMapping("/car")
    public ResultBean getCar() {
        List list = carService.getCarList();
        return success("购物车",list);
    }

}
